package com.zheng.damo01.HomeWeark05;

import java.util.Arrays;
import java.util.Comparator;

public class Test {
    public static void main(String[] args) {
        Integer[] arr={1,2,3,4,7,5,6};
        sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });
        System.out.println(Arrays.toString(arr));
    }
    public static <T> void sort(T[] arr,Comparator<? super T> c){
        Arrays.sort(arr,c);
    }
    public static <T extends Comparable<T>> void sort(T[] arr){
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                if (arr[j].compareTo(arr[j+1])>0){
                    T tamp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tamp;
                }
            }
        }
    }

}
